//移入移出
require(["../../static/conf/config.js"], function () {
    require(["jquery"], function ($) {
        let $city = $(".current-city")
        let $cityList = $(".current-city-list")
        let $message = $(".header-message")
        let $messageList = $(".message-list-header")
        let $applist = $("#app-list")
        let $APP = $("#APP")
        let $weixin = $(".footer-weixin")
        let $weixinErweima = $(".footer-weixin-erweima")
        let $footApp = $(".footer-app")
        let $appErweima = $(".footer-app-erweima")
        $weixin.mouseenter(function() {
            $weixinErweima.show("slow");
        })
        $weixin.mouseleave(function(){
            $weixinErweima.hide();
        })
        $footApp.mouseenter(function() {
            $appErweima.show("slow");
        })
        $footApp.mouseleave(function(){
            $appErweima.hide();
        })
        $APP.mouseenter(function() {
            $applist.show("slow");
        })
        $applist.mouseleave(function(){
            $applist.hide();
        })
        $city.mouseenter(function() {
            $cityList.show("slow");
        })
        $cityList.mouseleave(function(){
            $cityList.hide();
        })
        $message.mouseenter(function() {
            $messageList.show("slow");
        })
        $messageList.mouseleave(function(){
            $messageList.hide();
        })
    })
})


    require(["../../static/conf/config.js"], function () {
    require(["jquery"], function ($) {
        let telReg = /^[1][3,4,5,6,7,8][0-9]{9}$/;
        let passwordReg = /^[A-Za-z0-9]{8,20}$/;
        let randomCode = null;
        let status1=null;
        let status2=null;
        let status3=null;
        let status4=null;
        let status5=null;
        let status6=null;
        let telValue=null;
        let passwordValue=null;
        // $(".loginName").focus(function(){
        //     $(".reister-user").children().css({
        //         borderColor : "#dadada" 
        //     })
        // })
    //手机号码验证
    $(".loginName").blur(function(){
        telValue = $(".loginName").val().replace(/(^\s*)|(\s*$)/g,'');
        if(telValue==""){
            $(".err-text").children("i").css({
                display : "block"
            })
            $(".err-text").children("span").text("请输入正确的手机号码")
            $(".loginName").siblings("i").css({
                display : "none"
            })
            status1 = false;
        }
        else if(!telReg.test(telValue)){
            $(".err-text").children("i").css({
                display : "block"
            })
            $(".err-text").children("span").text("请输入正确的手机号码")
            $(".loginName").siblings("i").css({
                display : "none"
            })
            status1 = false;
            
        }
        else {
            $(".loginName").siblings("i").css({
                display : "block"
            })
            $(".err-text").children("i").css({
                display : "none"
            })
            $(".err-text").children("span").text("")
            status1 = true;
        }
    })
    //密码验证
    $(".password").blur(function(){
        passwordValue=$(".password").val().replace(/(^\s*)|(\s*$)/g, '');
        let strength = 0;
        if(passwordValue==""){
            $(".err-text").children("i").css({
                display  : "block"
            })
            $(".err-text").children("span").text("密码由8～20个字符，需同时包含英文和数字")
            $(".password").siblings("i").css({
                display : "none"
            }).addClass("weak")
            status2 = false;
            }
        else if(!passwordReg.test(passwordValue)){
            $(".err-text").children("i").css({
                display : "block"
            })
            $(".err-text").children("span").text("密码由8～20个字符，需同时包含英文和数字")
            $(".password").siblings("i").css({
                display : "none"
            }).addClass("weak")
            status2 = false;
            
        }
        else{
            if(/^[A-Za-z0-9]{1,7}/g.test(passwordValue)){
                strength = 1;
            }
            if(/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/g.test(passwordValue)){
                strength = 2;
            }
            if(/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{17,20}$/g.test(passwordValue)){
                strength = 3;
            }
        
            if(strength == 1){
                $(".err-text").children("i").css({
                display : "block"
                })
                $(".err-text").children("span").text("密码由8～20个字符，需同时包含英文和数字")
                $(".password").siblings("i").css({
                    display :　"block"
                }).removeClass("moderate").addClass("weak").removeClass("strong")  
                status2 = false;    
            }
            if(strength == 2){
                $(".err-text").children("i").css({
                display : "none"
                })
                $(".err-text").children("span").text("")
                $(".password").siblings("i").css({
                    display :　"block"
                }).addClass("moderate").removeClass("weak").removeClass("strong")
                status2 = true;
            }
            if(strength == 3){
                $(".err-text").children("i").css({
                display : "none"
                })
                $(".err-text").children("span").text("")
                $(".password").siblings("i").css({
                    display :　"block"
                }).removeClass("moderate").addClass("strong").removeClass("weak")
                status2 = true;
            }

        }

    })
    
    //确认密码
    $(".rePassword").blur(function(){
        var rePasswordValue = $(".rePassword").val().replace(/(^\s*)|(\s*$)/g, '');
        if(rePasswordValue == "" || rePasswordValue == undefined ){
            $(".err-text").children("i").css({
                display : "block"
            })
            $(".err-text").children("span").text("两次密码输入不一致")
            $(".rePassword").siblings("i").css({
                display : "none"
            })
                status3 = false;
        }
        if(rePasswordValue !== $(".password").val()){
            $(".err-text").children("i").css({
                display : "block"
            })
            $(".err-text").children("span").text("两次密码输入不一致")
            $(".rePassword").siblings("i").css({
                display : "none"
            })
                status3 = false;
        }
        if(rePasswordValue == $(".password").val() && rePasswordValue !== ""){
            $(".err-text").children("i").css({
                display : "none"
            })
            $(".err-text").children("span").text("")
            $(".rePassword").siblings("i").css({
                display : "block"
            })
                status3 = true;
        }
    })
    
    //图片验证码验证
    $(".code").blur(function(){
        let codeValue = $(".code").val().replace(/(^\s*)|(\s*$)/g,'')
        if(codeValue !== "bpn7"){
            $(".err-text").children("i").css({
                display : "block"
            })
            $(".err-text").children("span").text("图形验证码错误")
            $(".code").siblings("i").css({
                display : "none"
            })
            status4 = false;
        } 
        if(codeValue == ""){
            $(".err-text").children("i").css({
                display : "block"
            })
            $(".err-text").children("span").text("请输入图形验证码")
            $(".code").siblings("i").css({
                display : "none"
            })
            status4 = false;
        }
        if(codeValue == "bpn7"){
            $(".err-text").children("i").css({
                display : "none"
            })
            $(".err-text").children("span").text("")
            $(".code").siblings("i").css({
                display : "block"
            })
            status4 = true;
        }
    })

    //短信验证码
    $(".regiGetCode").click(function(){
        let random1 = parseInt(Math.random()*10);
        let random2 = parseInt(Math.random()*10);
        let random3 = parseInt(Math.random()*10);
        let random4 = parseInt(Math.random()*10);
        let random5 = parseInt(Math.random()*10);
        let random6 = parseInt(Math.random()*10);
        randomCode = parseInt(`${random1}${random2}${random3}${random4}${random5}${random6}`)
        $(this).text(randomCode)
    })
    $(".authCode").blur(function(){
        let telCodeValue = $(".authCode").val().replace(/(^\s*)|(\s*)$/g,'')
        if(telCodeValue !== randomCode){
            $(".err-text").children("i").css({
                display : "block"
            })
            $(".err-text").children("span").text("短信验证码错误")
            $(".authCode").siblings("i").css({
                display : "none"
            })
            status5 = false;
        }
        if(telCodeValue == randomCode){
            $(".err-text").children("i").css({
                display : "none"
            })
            $(".err-text").children("span").text("")
            $(".authCode").siblings("i").css({
                display : "block"
            })
            status5 = true;
        }
    })

    //生日接收（存储到后台用户信息当中）

    //勾选会员协议和隐私保护政策
    $(".login-button").click(function(){
        if($(".agree").is(":checked")){
            status6 = true;
        }
        else{
            $(".err-text").children("i").css({
                display : "block"
            })
            $(".err-text").children("span").text("请勾选21客会员协议和隐私保护政策")
            status6 = false;
        }
        //设置本地存储
        let jsonDate = JSON.parse(localStorage.getItem('userinfo'));
            let arr = [];
        for(let i in jsonDate){
            arr.push(jsonDate[i]);
        }
        if(status1==true && status2==true && status3==true && status4==true && status5==true && status6==true){
            arr.push({
                username : telValue,
                password :　passwordValue
            })
            localStorage.setItem('userinfo',JSON.stringify(arr));
            alert("正在转为登录界面")
            setTimeout(function(){
                window.location = "../login/login.html"
            },2000)

        }

    })


    })
})
